package cn.knowei.miaosha.controller;

import cn.knowei.miaosha.enums.DelayTypeEnum;
import cn.knowei.miaosha.producer.DelayMessageProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @Author: knowei
 * @Description:
 * @Date: Create in 19:39 2023-04-07
 */
@RestController
@Slf4j
@RequestMapping("rabbitmq")
public class RabbitMQController {

    @Resource
    DelayMessageProducer producer;

    @RequestMapping("send")
    public void send(String message, Integer type) {
        log.info("消息{} -- 类型{}", message, type);
        producer.send(message, Objects.requireNonNull(DelayTypeEnum.display(type)));
    }
}
